class Solution {
public:
    int searchInsert(vector<int>& nums, int target) 
    {

        int temp = 0;

        for(int i = 0; i < nums.size(); i++)
        {
            // FIXME: It is better do not use blank befor `else`, your style is
            // not good, please force yourself to change the convention
            if(target == nums[i])
            {
                temp = i;
                break;
            }
            else if(target < nums[0])
            {
                temp = 0;    
                break;
            }
            else if(target > nums[nums.size() - 1])
            {
                temp = nums.size();
                break;
            }
            else if(target > nums[i] && target < nums[i + 1])
            {
                temp = i + 1;
                break;
            }

        }

        return temp; 
    }
};

//if-else顺序查找